package com.virtual.repository.common.managers;

import com.virtual.repository.common.model.ModelConfiguration;
import com.virtual.repository.common.queries.Query;
import com.virtual.repository.common.queries.ResultEntity;

/**
 * The interface for all query parsers, responsible for translating the entire query to the entity's names 
 * and parsing the result entities to the object's names.
 * @author kchaber
 *
 */
public interface IQueryParser {

	/**
	 * Translates the entire query fields - builded by the {@link com.virtual.repository.common.queries.IQueryBuilder}
	 * to the entity's names notation.
	 * @param query the entire query 
	 * @param modelConfig the configuration model
	 * @return translated query
	 * @throws Exception
	 */
	public abstract Query translateQuery(Query query, ModelConfiguration modelConfig) throws Exception;

	/**
	 * Parses the entity's names from the query result object to the expected result object field's names.
	 * @param resultEntity the result entity received from the {@link com.virtual.repository.plugins.api.IDatabasePlugin}
	 * @param modelConfig the configuration model
	 * @param expectedClass the expected result class
	 * @return parsed result object
	 * @throws Exception
	 */
	public abstract <TYPE extends Object> TYPE parseSingleResult(ResultEntity resultEntity, 
			ModelConfiguration modelConfig, Class<TYPE> expectedClass) throws Exception;
}